package manong.mapper;

import manong.beans.Stu;
import manong.beans.StuQuery;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.session.RowBounds;

import java.util.List;
@Mapper
public interface StuMapper {
  
    long countByExample(StuQuery example);

    int deleteByExample(StuQuery example);

   
    @Delete({
        "delete from Stu",
        "where id = #{id,jdbcType=INTEGER}"
    })
    
    int deleteByPrimaryKey(Integer id); 
    @Insert({
        "insert into stu (stu_name, class_name, ",
        "class_id, stu_sno, ",
        "statu, mark)",
        "phone, speciality)",
        "values (#{studentName,jdbcType=VARCHAR}, #{className,jdbcType=VARCHAR}, ",
        "values (#{classid,jdbcType=INTEGER}, #{sno,jdbcType=INTEGER}, ",
        "#{statu,jdbcType=INTEGER}, #{mark,jdbcType=VARCHAR}, ",
        "#{studentPhone,jdbcType=VARCHAR}, #{speciality,jdbcType=VARCHAR}, ",
    })    
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="id", before=false, resultType=Integer.class)
    int insert(Stu record);

    int insertSelective(Stu record);

    List<Stu> selectByExampleWithRowbounds(StuQuery example, RowBounds rowBounds);

   
    Stu selectOneByExample(StuQuery example);

    List<Stu> selectByExample(StuQuery example);

   
    @Select({
        "select",
        "id, stu_name, class_name, class_id, stu_sno,statu, mark,phone,speciality",
        "from stu",
        "where id = #{id,jdbcType=INTEGER}"
    })
    @ResultMap("manong.mapper.StuMapper.BaseResultMap")
    Stu selectByPrimaryKey(Integer id);

    int updateByExampleSelective(@Param("record") Stu record, @Param("example") StuQuery example);

   
    int updateByExample(@Param("record") Stu record, @Param("example") StuQuery example);

   
    int updateByPrimaryKeySelective(Stu record);

   
    @Update({
        "update teacher",
        "set stu_name = #{studentName,jdbcType=VARCHAR},",
          "class_name = #{className,jdbcType=VARCHAR},",
          "class_id = #{classid,jdbcType=INTEGER},",
          "stu_sno = #{sno,jdbcType=INTEGER},",
          "statu = #{statu,jdbcType=INTEGER}",
          "mark = #{mark,jdbcType=VARCHAR}",
          "phone = #{studentPhone,jdbcType=VARCHAR}",
          "speciality = #{speciality,jdbcType=VARCHAR}",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(Stu record);

   
    int insertOrUpdate(Stu record);

   
    int insertOrUpdateSelective(Stu record);

 
    int batchInsert(@Param("list") List<Stu> list);

     int batchInsertSelective(@Param("list") List<Stu> list, @Param("selective") Stu.Column ... selective);
}